package org.ucas.faker.web.fetcher.op;

import org.ucas.faker.web.fetcher.meta.ColumnField;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class OrderBy  implements Serializable {

  public List<ColumnField> columns = new ArrayList<>();

  public boolean ascend = true;

  public String sql() {
    String res = "ORDER BY " + columns.stream().map(ColumnField::sql).collect(Collectors.joining(","));
    return ascend? res : res + " DESC ";
  }
}
